
# ifndef __DFX_PROGRAM_OGL_H__
# define __DFX_PROGRAM_OGL_H__

# include <GL/glew.h>
# include <GL/GL.h>

# include "dfxProgram.h"

namespace DFX
{    
    class Program_OGL : public Program
    {
    private:

        typedef std::map<String, GLuint> ShaderMap;
                
        GLuint          mShaders[SHADER_TYPE_MAX];
        GLuint          mHandle;
        ShaderMap       mShaderMap;        

    public:

        Program_OGL(GraphicsDevice *gd, const String &name);
        ~Program_OGL();

        DFXRESULT LoadShader(SHADER_TYPE shaderType, InputStream *stream);
        DFXRESULT Link();
        DFXRESULT Destroy();

        void Bind();
        void BindVertexFormat(VertexFormat *format);

        UInt32 GetConstantLocation(const String &name);

        void SetVector2(UInt32 loc, const Vector2 &v);
        void SetVector3(UInt32 loc, const Vector3 &v);
        void SetVector4(UInt32 loc, const Vector4 &v);

        void SetVector2(UInt32 loc, Float32 x, Float32 y);
        void SetVector3(UInt32 loc, Float32 x, Float32 y, Float32 z);
        void SetVector4(UInt32 loc, Float32 x, Float32 y, Float32 z, Float32 w);

        void SetFloat(UInt32 loc, Float32 v);
        void SetTexture(UInt32 loc, UInt32 unit, Texture *t);

        void SetVector2(const String &name, const Vector2 &v);
        void SetVector3(const String &name, const Vector3 &v);
        void SetVector4(const String &name, const Vector4 &v);

        void SetVector2(const String &name, Float32 x, Float32 y);
        void SetVector3(const String &name, Float32 x, Float32 y, Float32 z);
        void SetVector4(const String &name, Float32 x, Float32 y, Float32 z, Float32 w);

        void SetFloat(const String &name, Float32 v);
        void SetTexture(const String &name, UInt32 unit, Texture *t);
    };
}

# endif